BranderUser = {
	data: {},
	initVue: function() {
		let vue = {
			el: '.brander-user-box',
			data: BranderUser.data,
			methods: {
				getPicUrl: function() {
					return Imger.getUrl(BranderUser.data.brander,Cons.IMAGE_TYPE.COLOR_250);
				},
				picClick:function(){
					if(BranderUser.data.brander.picColor>0){
						BranderUser.data.brander.picColor=0;
						Msger.info('已显示原图');
					}else{
						BranderUser.data.brander.picColor=2;
						Msger.info('已显示彩图');
					}
				},
				isTurned:function(){
					return !bbk.isEmpty(BranderUser.data.brander.oldSqName);
				},
				hasError:function(){
					return !bbk.isEmpty(this.getErrorMsg());
				},
				getFirstSellerQr:function(){
					if(bbk.isEmpty(BranderUser.data.concat.qrcode_url)){
						return ;
					}
					let text = BranderUser.data.concat.qrcode_url;
					return text;
				},
				getPhoneHtml:function(item){
					return '<a class="blue" href="tel:'+item.phone+'"/>'+item.phone+'</a>';
				},
				getPriceType:function(){
					if(bbk.isEmpty(this.firstSeller)){
						return '';
					}
					let arr=Cons.PRICE_TYPE.getByNum(this.firstSeller.priceType).split(',');
					let html='';
					for(let i=0;i<arr.length;i++){
						if(arr[i].indexOf('不')>-1){
							html+=arr[i]+'，';
						}else{
							html+=arr[i]+'，';
						}
					}
					html=html.substr(0,html.length-1);
					return html;
				},
				getPrice:function(item){
					return BranderUser.data.brander.price+'元';
				},
				getLastLoginTime:function(){
					// if(!bbk.isEmpty(this.firstSeller.lastLoginTime)){
					// 	return this.firstSeller.lastLoginTime.replace('T',' ');
					// }
					var date = new Date();
					return date.getFullYear() +'-'+ bbk.getTwo(date.getMonth() + 1) +'-'+ bbk.getTwo(date.getDate());
				},
				getNow:function(){
					let now=new Date();
					return now.getFullYear()+'-'+bbk.getTwo(now.getMonth()+1) +'-'+bbk.getTwo(now.getDate())+' '+bbk.getTwo(now.getHours())+':'+bbk.getTwo(now.getMinutes())+':'+bbk.getTwo(now.getSeconds());
				},
				hasBrother:function(){
					return !bbk.isEmpty(BranderUser.data.brander.brother);
				},
				getBrother:function(){
					let leiNum=this.brander.brother.length/3;
					let brother='<a class="blue" target="_blank" href="/?page=simple_list&md='+this.brander.md+'">'+this.brander.brother.replace(new RegExp(';','g'),'类;')+'</a>';
					return brother+'(共'+leiNum+'类)';
				},
				getSqNum:function(){
					if(BranderUser.data.brander.sqNum==0){
						return '<span onclick="BranderUser.updateSqNum()">系统未完成统计预计2个小时内完成</span>';
					}
					if(BranderUser.data.brander.sqNum>110){
						return BranderUser.data.brander.sqNum+' <span class="red">（请充分认识转让的风险）</span>';
					}
					return BranderUser.data.brander.sqNum;
				},
				showWxQr:function(item){
					let srcData = bbk.getQrSrc({
						text: item.wxQrUrl,
						width: 200,
						height: 200
					});
					layer.open({
						title:'<i class="layui-icon layui-icon layui-icon-login-wechat" style="color:green"></i>扫一扫，加「'+item.name+'」微信',
						type: 1,
						shadeClose:true,
						content: '<div class="more-seller-content-box flex-center">' +
							'<img src="' + srcData + '">' +
							'</div>'+
							'<div class="center hover">价格不实?点此投诉(开发中)</div>',
						area: ['100%', '80%'],
					});
				},
				getDateStar:function(item){
					let date=item.lastLoginTime.split('T')[0];
					return date;
				},
				
			}
		}
		new Vue(vue);
	},
	loadBranderUser: function() {
		let branderId = bbk.getUrlVal('brander_id');
		/*if (branderId.length != 18) {
			Msger.error("参数错误，请告知客服，谢谢");
			return;
		}*/
		let ajax = {
			url: 'https://www.dunmama.cn/trademarks/getdetail.html?tid='+branderId,
			data: {
				tid: branderId,
				host:location.host
			},
			success: function(res) {
		        res.data.brander = res.data;
				BranderUser.data = res.data;
				BranderUser.data.isShowAllSeller=false;
				$('title').html(res.data.brander.name+'-'+res.data.brander.lei+'类')
				if(bbk.isEmpty(res.data)){
					Msger.error('当前商标未上架');
				}else{
					BranderUser.initVue();
				}
			},
			error: function(res) {
				if (res.code == Cons.ERROR_CODE.NOT_LOGIN) {
					Login.login(false, function() {
						bbk.reload(1.5);
					})
					return false;
				}
			}
		}
		bbk.ajax(ajax);
	},
	init: function() {
		this.loadBranderUser();
	},

}

window.onload = function() {
	BranderUser.init();
	
}
